package br.com.ss.bean;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import br.com.ss.entity.TipoPrancha;
import br.com.ss.enumeration.EMensageSucess;
import br.com.ss.facade.TipoPranchaFacade;
import br.com.ss.util.FacesUtil;


@ManagedBean(name = "tipoPranchaCRUDBean")
@RequestScoped
public class TipoPranchaCRUDBean extends AbstractMenageBean {
	
	@EJB
    private TipoPranchaFacade tipoPranchaFacade;
 
    private TipoPrancha tipoPrancha;
    
    @PostConstruct
    public void init() {
    	limpar();
    }
    
    private void limpar(){
    	tipoPrancha = new TipoPrancha();
    }
 
    public List<TipoPrancha> getAllTipoPrancha() {
        return tipoPranchaFacade.findAll();
    }

    public void criarTipoPrancha(){
    	tipoPranchaFacade.save(tipoPrancha);
    	
    	FacesUtil.criarMensagemSucesso(EMensageSucess.INCLUIDO_COM_SUCESSO_, new Object[]{"Tipo Prancha"});
    	
    	closeDialog("criarTipoPrancha");
    }
  
  //===============================================================================================================================
    
	public TipoPrancha getTipoPrancha() {
		return tipoPrancha;
	}

	public void setTipoPrancha(TipoPrancha tipoPrancha) {
		this.tipoPrancha = tipoPrancha;
	}
 
   	

}
